package cn.itcast.erp.action;

import cn.itcast.erp.biz.IEmpBiz;
import cn.itcast.erp.entity.Emp;
import com.alibaba.fastjson.JSON;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class EmpAction{

    private IEmpBiz empBiz;
    public void setEmpBiz(IEmpBiz empBiz) {
        this.empBiz = empBiz;
    }
    private Emp emp1;
    private Emp emp2;
    private Object param;

    public Emp getEmp1() {
        return emp1;
    }

    public void setEmp1(Emp emp1) {
        this.emp1 = emp1;
    }

    public Emp getEmp2() {
        return emp2;
    }

    public void setEmp2(Emp emp2) {
        this.emp2 = emp2;
    }

    public Object getParam() {
        return param;
    }

    public void setParam(Object param) {
        this.param = param;
    }

    /**
     * 扩展多条件查询dep
     */
    public void getListByCondition() throws IOException {
        List<Emp> empList = empBiz.getListByCondition(emp1, emp2, param);
        String jsonString = JSON.toJSONString(empList);
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setContentType("application/json; charset=utf-8");
        response.getWriter().print(jsonString);
    }

}
